<script>
import PPMForm from "@/crm3.0part7-ppm/core/ppmForm.vue";
export default {
  name: "ggw11613",
  mixins: [PPMForm],
  data() {
    return {};
  },
  mounted() {
    // debugger;
    this.init();
  },
  created() {
    // this.init();
  },
  computed: {},
  methods: {
    //初始化
    init() {
      this.formData["10461606-100012749"].isshow = false;
      var cacheInfo = JSON.parse(localStorage.getItem("cacheInfo"));
      //节点名称
      this.formData["4444-141000044"].value = cacheInfo.nodeName;
      /**
       *  填报期限
        1、如果需求单要求完成日期为空默认为审核日期+3个工作日
        2、如果B2 来单为审核日期+3个工作日
        3、当查询型需求单要求完成日期大于2个工作日,资源调查期限为需求单审核后2个工作日
        4、当查询型需求单要求完成日期小于等于2个工作日,资源调查期限与“需求单要求完成日期”一致；
       */
      let reqType = cacheInfo.reqType;
      let reqAudDate = cacheInfo.reqAudDate;
      console.log("reqAudDate:", reqAudDate);
      // this.formData["4444-100012611"].value = cacheInfo.taskReqDate;
      if (null == cacheInfo.taskReqDate || " " == cacheInfo.taskReqDate) {
        this.formData["4444-100012611"].value = cacheInfo.reqAudDate;
      }
      this.formData["4444-100012611"].value = this.$util.dateFormat(
        cacheInfo.taskReqDate,
        "yyyy-MM-dd"
      );
      //填报日期
      this.formData["4444-100012440"].value = this.$util.dateFormat(
        new Date(),
        "yyyy-MM-dd"
      );
      //填报人
      this.formData["4444-100012377"].value = cacheInfo.staffName;

      //联系电话
      this.formData["4444-141000045"].value = cacheInfo.linkTel;

      //带宽除IP虚拟专网的五个产品和宽带卫星productId
      let productId = cacheInfo.productId;
      if (
        productId == "80008002" ||
        productId == "80008019" ||
        productId == "80008003" ||
        productId == "80008001" ||
        productId == "80008007" ||
        productId == "80008062"
      ) {
        //将中国侧半电路资源隐藏,预计工期(工作日)隐藏，中国侧半电路资源备注隐藏
        this.formData["4444-100013718"].isshow = false;
        this.formData["4444-100013721"].isshow = false;
        this.formData["4444-100013724"].isshow = false;
      }
    },

    //长途中继资源
    source() {
      if (this.formData["4444-100013716"].value == "9005001") {
        this.SetRequired({
          attrName: "预计工期(工作日)",
          formkey: "4444-100013719",
          reqName: "empty",
          reqStatus: false,
        });
        if (this.formData["4444-100013717"].value == "9005001") {
          this.formData["4444-141000051"].text = "具备";
          this.formData["4444-141000051"].value = "9005001";
        }
        this.formData["4444-100013719"].value = " ";
      }
      if (this.formData["4444-100013716"].value == "9005002") {
        this.formData["4444-141000051"].text = "不具备";
        this.formData["4444-141000051"].value = "9005002";
        this.SetRequired({
          attrName: "预计工期(工作日)",
          formkey: "4444-100013719",
          reqName: "empty",
          reqStatus: true,
        });
      }
    },

    //长途中继资源预计工作日
    TIMELIMITA() {
      this.SetRequired({
        attrName: "预计工期(工作日)",
        formkey: "4444-100013719",
        reqName: "pinteger",
        reqStatus: true,
      });
      if (this.formData["4444-100013716"].value == "9005001") {
        if (this.formData["4444-100013719"].value > 20) {
          this.$alert("预计工作日不能超过20天!", "提示", {
            type: "warning",
            confirmButtonText: "关闭",
          });
          this.formData["4444-100013719"].value = "";
        }
      }
      if (this.formData["4444-100013716"].value == "9005002") {
        if (this.formData["4444-100013719"].value <= 20) {
          this.$alert("预计工作日需大于20天!", "提示", {
            type: "warning",
            confirmButtonText: "关闭",
          });
          this.formData["4444-100013719"].value = "";
        }
      }
    },

    //端口资源
    PortSource() {
      if (this.formData["4444-100013717"].value == "9005001") {
        this.SetRequired({
          attrName: "预计工期(工作日)",
          formkey: "4444-100013720",
          reqName: "empty",
          reqStatus: false,
        });
        if (this.formData["4444-100013716"].value == "9005001") {
          this.formData["4444-141000051"].text = "具备";
          this.formData["4444-141000051"].value = "9005001";
        }
        this.formData["4444-100013720"].value = " ";
      }
      if (this.formData["4444-100013717"].value == "9005002") {
        this.formData["4444-141000051"].text = "不具备";
        this.formData["4444-141000051"].value = "9005002";
        this.SetRequired({
          attrName: "预计工期(工作日)",
          formkey: "4444-100013720",
          reqName: "empty",
          reqStatus: true,
        });
      }
    },

    //长途中继资源预计工作日
    TIMELIMITB() {
      this.SetRequired({
        attrName: "预计工期(工作日)",
        formkey: "4444-100013720",
        reqName: "pinteger",
        reqStatus: true,
      });
      if (this.formData["4444-100013717"].value == "9005001") {
        if (this.formData["4444-100013720"].value > 20) {
          this.$alert("预计工作日不能超过20天!", "提示", {
            type: "warning",
            confirmButtonText: "关闭",
          });
          this.formData["4444-100013720"].value = "";
        }
      }
    },

    //电路维护等级是否具备当具备时，可提供电路维护等级字段隐藏
    CircuitLevel() {
      if (this.formData["10461606-100012783"].value == "9005001") {
        this.formData["10461606-100012749"].isshow = false;
      }
      if (this.formData["10461606-100012783"].value == "9005002") {
        this.formData["10461606-100012749"].isshow = true;
      }
    },
  },
};
</script>

